<template>
  <div id="app">
    <!-- 主要内容区域 -->
    <van-nav-bar
  title="标题"
  left-text="返回"
  left-arrow
  @click-left="onClickLeft"
/>
    <transition name="fade" mode="out-in">
      <router-view></router-view>
    </transition>

    <van-dialog :show="showDialog" title=""   :show-cancel-button="false" :showConfirmButton="false"  confirmButtonText="登录">
      <LoginPopup @login-success="onConfirm" />
    </van-dialog>
 
    <!-- 底部导航栏 -->
    <van-tabbar route active-color="#ee0a24" inactive-color="#000">
      <van-tabbar-item replace to="/" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item replace to="/hospitalInfo" icon="search"
        >医院信息</van-tabbar-item
      >
      <van-tabbar-item replace to="/myInfo" icon="friends-o"
        >我的</van-tabbar-item
      >
    </van-tabbar>
  </div>
</template>

<script>
/* eslint-disable */
import Home from "@/view/Home.vue";
import LoginPopup from "./components/login/LoginPopup.vue";
import Register from "./components/registration/Register.vue";
import { ref ,onMounted,getCurrentInstance} from "vue";
import LocalStorageUtil from '@/utils/localStorageUtil';
import { useAuthStore } from "@/stores/authStore";

export default {
  name: "App",
  components: {
    Home: Home,
    LoginPopup,
    Register
  },
  
  setup() {
    const authStore=useAuthStore();
    const { proxy } = getCurrentInstance(); // 获取当前实例
    const showDialog = ref(false);
    const onConfirm = () => {
      // 如果你需要在这里执行一些操作，比如验证表单数据等
      console.log('用户点击了登录');
      // 关闭对话框
      showDialog.value = false;
    };
    const showDialogFun=()=>{
      showDialog.value = true;
    }
    
    onMounted(()=>{
      console.log("App.Vue_mounted");
      const token= LocalStorageUtil.getLocalStorage("token")
      console.log("token--->>",token);
      if(token==null||token==undefined){
        showDialogFun();
       }else{
        authStore.referenceStatus();
        // proxy.onConfirm();
       }
      
    })
  
    const onClickLeft = () => history.back();
    return { showDialog ,onConfirm,onClickLeft};
  },
  mounted() {
   
  },
};
</script>

<style>
#app {

}
</style>
